#ifndef __NONAME_WORKTHREAD_H__
#define __NONAME_WORKTHREAD_H__

#define NONAME_LIB_USE

#include <ntifs.h>
#include "nm_mem.h"

typedef VOID (__stdcall *WORKITEMPROC)(PVOID Context);

class kworkthread
{
public:
	kworkthread();
	void Release();

	VOID InsertItem(WORKITEMPROC Address, PVOID Context, PRKEVENT *Event);
	HANDLE GetWorkThreadId() { return m_ClientId.UniqueThread; }

protected:
	static void __stdcall Run(PVOID Context);

private:

	typedef struct _WORK_ITEM {
		LIST_ENTRY Next;
		WORKITEMPROC StartAddress;
		PVOID Context;
		KEVENT Event;
	} WORK_ITEM, *PWORK_ITEM;
private:
	klookaside m_Lookaside;
	KEVENT m_InsertEvent;
	KEVENT m_SyncEvent;
	HANDLE m_ThreadHandle;
	CLIENT_ID m_ClientId;
	LIST_ENTRY m_ListHeader;
	KSPIN_LOCK m_Lock;
	BOOLEAN	m_Stop;
};


#endif